﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Ict.DataAccess;
using CSF.BusinessCore.BLL;
using CSF.Security.Data;

namespace CSF.Security.BLL
{
    internal class UserAccountRoleBLL : LogCreateLogic<UserAccountRole>
    {
        internal List<int> GetRoleIdsByUser(int userId)
        {
            var q = from p in DataContext.Select<UserAccountRole>()
                    where p.UserId == userId
                    select p.RoleId;

            return q.ToList();
        }

        internal List<int> GetRoleIdsByUser(string userName)
        {
            var q = from p in DataContext.Select<UserAccountRole>()
                    join p1 in DataContext.Select<UserAccount>() on p.UserId equals p1.Id
                    where p1.UserName == userName && p1.IsApproved && !p1.IsDisable && !p1.IsLockout
                    select p.RoleId;

            return q.ToList();
        }
    }
}
